<template>
  <div class="dept">
      <el-cascader
        v-model="value"
        :options="DepList"
        :props="optionProps"
        @change="handleChange"
        ></el-cascader>
    </div>
</template>
<script>
    export default {
        name: 'dept',
        created() {
            this.findlist()
            if (this.deptID) {
                this.$http({
                    url: this.$http.adornUrl('/app/deptinfoOne/' + this.deptID),
                    method: 'get',
                }).then(({
                    data
                }) => {
                    // if (data && data.code === 0) {
                    //     this.DepList = data.data

                    // }
                    this.value = data.data
                })
            }
        },
        props: {
            id: {
                type: "",
                required: true
            },

        },

        data() {
            return {
                value: [],
                optionProps: {
                    value: 'deptId',
                    label: 'deptName',
                    children: 'children'
                },
                DepList: [],
                deptID: this.id

            };
        },
        methods: {
            handleChange(value) {
                console.log(value);
                var end = value.slice(-1).toString();
                this.$emit('input', end)
            },
            findlist() {
                this.$http({
                    url: this.$http.adornUrl('/app/deptInfo/look'),
                    method: 'get',
                }).then(({
                    data
                }) => {
                    if (data && data.code === 0) {
                        this.DepList = data.data

                    }
                })
            },
        }
    };
</script>
<style lang="scss">
   
</style>
